package com.Crawlzongheng;

import java.util.List;
import java.util.concurrent.TimeUnit;

import com.zonghengdb.ZongHengDB;

public class UpdateListThread extends Thread{
	private boolean flag=false;
	private String url ="";
	private int frequency;
	
	public UpdateListThread(String name,String url,int frequency) {
		super(name);
		this.url=url;
		this.frequency =frequency;
	}
	
	
	
	@Override
	public void run() {
		flag=true;
		ZongHengDB db=new ZongHengDB();
		while(flag){
			try {
				UpdateList updateList = new UpdateList(this.url);
				List<String> urls = updateList.getPageUrl(true);
				db.saveInfoUrls(urls);
				TimeUnit.SECONDS.sleep(this.frequency);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		super.run();
	}
	public static void main(String[] args) {
		UpdateListThread thread = new UpdateListThread("updateList", "", 30);
		thread.start();
	}
}
